package cn.edu.scau.cmi.chenjiale.adapter;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

/**
 * 主启动类
 * 
 * @author chen
 *
 */
public class AdapterApplication extends Application{

	@Override
	public void start(Stage primaryStage) throws Exception {
		BorderPane pane = new BorderPane();
		
		HBox hbox = new HBox(5);
		hbox.setAlignment(Pos.CENTER_LEFT);
		Button classBtn = new Button("类适配器");
		Button objectBtn = new Button("对象适配器");
		hbox.getChildren().addAll(classBtn,objectBtn);
		
		TextArea textArea = new TextArea();
		
		pane.setTop(hbox);
		pane.setCenter(textArea);
		
		classBtn.setOnAction(e->{
			AdapterOfClass adapter = new AdapterOfClass();
			textArea.setText(adapter.convertVolt());
		});
		
		objectBtn.setOnAction(e->{
			AdapterOfObject adapter = new AdapterOfObject(new Television());
			textArea.setText(adapter.convertVolt());
		});
		
		Scene scene = new Scene(pane,400,300);
		primaryStage.setScene(scene);
		primaryStage.setTitle("适配器");
		primaryStage.show();
	}
	
	public static void main(String[] args) {
		Application.launch(args);
	}
   
}
